package com.luych.toolbox.common.feign.view.data.service;

import com.luych.toolbox.common.enums.DataAgentStatus;
import com.luych.toolbox.common.enums.DataSourceType;
import com.luych.toolbox.common.feign.FeignView;
import com.luych.toolbox.common.feign.view.base.service.UserView;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel("数据代理")
public class DataAgentView extends FeignView {

    @ApiModelProperty("名称")
    private String name;
    @ApiModelProperty("类型")
    private DataSourceType type;
    @ApiModelProperty("IP地址")
    private String host;
    @ApiModelProperty("端口")
    private Integer port;
    @ApiModelProperty("用户名")
    private String user;
    @ApiModelProperty("路径")
    private String path;
    @ApiModelProperty("状态")
    private DataAgentStatus status;
    @ApiModelProperty("责任人")
    private UserView owner;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public DataSourceType getType() {
        return type;
    }

    public void setType(DataSourceType type) {
        this.type = type;
    }

    public String getTypeValue() {
        return type == null ? null : type.getValue();
    }

    public String getTypeDriver() {
        return type == null ? null : type.getDriver();
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public DataAgentStatus getStatus() {
        return status;
    }

    public String getStatusValue() {
        return status == null ? null : status.getValue();
    }

    public void setStatus(DataAgentStatus status) {
        this.status = status;
    }

    public UserView getOwner() {
        return owner;
    }

    public void setOwner(UserView owner) {
        this.owner = owner;
    }

    public String getOwnerId() {
        return owner == null ? null : owner.getId();
    }

    public String getUrl() {
        if (host == null || port == null || user == null) {
            return null;
        }
        return String.format("%s@%s:%d", user, host, port);
    }
}
